<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>  
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'login.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="<%=basePath %>/jquery/jquery-1.4.4.min.js"></script>
  	<script type="text/javascript">
		 $(document).ready(function() {
			$("#submit").click(function(){
				var name = $.trim($("#name").val());
				var password = $.trim($("#password").val());
				if(name.length == 0) {
					alert('请填写用户名');
					return false;
				}
				if(password.length == 0) {
					alert('请填写密码');
					return false;
				}
			$.post("${pageContext.request.contextPath }/login.do",
				{	name: $("#name").val(),
					password: $("#password").val() },
				function (data){
					 if(data == "OK") {
					 	alert('登陆成功！');
					 	window.location.href='${pageContext.request.contextPath }/details/result.do';
					 }else {
					 	alert('登陆失败！');
					 	$("#name").val("");
					 	$("#password").val("");
					 }
				}); 
            }); 
		}); 
	</script>
  
  </head>
  
  <body>
	<table align="center" border="1">
		<tr>
			<td>姓名:</td>
			<td><input type="text" id="name" /></td>
		</tr>
		<tr>
			<td>密码:</td>
			<td><input type="password" id="password" /></td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input type="submit" id="submit" />
			</td>
		</tr>
	</table>
  </body>
</html>
